package com.xncoding.encrypt.enums;

import java.util.function.Function;

public enum SensitiveStrategy {

    // 身份证
    ID_CARD(s -> s.replaceAll("(\\d{3})\\d{12}(\\w{3})", "$1*****$2")),
    // 手机号
    PHONE(s -> s.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2")),
    // 地址
    ADDRESS(s -> s.replaceAll("(\\S{3})\\S{2}\\S*(\\S{2})", "$1********$2"));

    private final Function<String, String> serialize;

    SensitiveStrategy(Function<String, String> serialize) {
        this.serialize = serialize;
    }

    public Function<String, String> serialize() {
        return serialize;
    }

}